package com.longteng.testng;

import com.longteng.testng.binder.Binder;
import com.longteng.testng.param.IGenerator;
import com.longteng.testng.param.Row;

import java.lang.reflect.Method;
import java.util.Iterator;

/**
 * Created by sky on 15-12-24
 */
public class BenchMarkIterator implements Iterator<Object[]> {


    private Binder binder;

    private Method method;

    private Iterator<Row> rowIterator;

    public BenchMarkIterator(BenchMark.Config config, Method method){
        this.method = method;
        this.binder = config.getBinder();
        IGenerator generator = config.getGenerator();
        this.rowIterator = generator.generate(method).iterator();
    }

    @Override
    public boolean hasNext() {
        return rowIterator.hasNext();
    }

    @Override
    public Object[] next() {
        Row row = rowIterator.next();
        return binder.bind(row,method);
    }
}
